#ifndef		___DATA_HOST_IMP___
#define		___DATA_HOST_IMP___


#include "DataSessionMgr.h"

//
//
//
//
class DataHost
{
public:
	enum
	{
		num_working_thread	=	4,
		num_session_mgrs	=	2,
	};


	DataHost();
	virtual ~DataHost();

	//
	//	start & stop hosting
	//
	virtual bool start();
	virtual bool stop();
	virtual bool wait();

	//
	//	session recycle & reuse
	//
	virtual bool	createSession(DataSession*& pSes);
	virtual	bool	releaseSession(DataSession*  pSes);

	//
	//	session start & end
	//
	virtual void onSessionStart(DataSession* pSes, const boost::system::error_code& error);
	virtual void onSessionEnd(DataSession* pSes);
protected:

	void post_accept();

protected:
	boost::asio::io_service			m_theIoSvc;
	boost::thread					m_theThreads[num_working_thread];
	boost::asio::io_service::work	m_theEmptyWork;

	boost::asio::ip::tcp::endpoint	m_theEndPoint;
	boost::asio::ip::tcp::acceptor	m_theAcceptor;

	DataSessionMgr*					m_theSesMgrs[num_session_mgrs];
};

#endif
